import Vue from "vue";
import Vuex from "vuex";

Vue.use(Vuex);

export default new Vuex.Store({
  state: {
    fns: {},
  },
  mutations: {
    addFns(state, { url, cb }) {
      state.fns[url] = cb;
    },
    delFn(state, url) {
      delete state.fns[url];
    },
    cancelFns(state) {
      for (let key in state.fns) {
        state.fns[key]();
      }
    },
  },
});
